<%@ page language="java" import="java.sql.*" contentType="text/html;charset=UTF-8" %>
<%//@ page language="java" import="java.sql.*" contentType="text/html;charset=KSC5601" %>


<%
    request.setCharacterEncoding("UTF-8");
  
	String sName = request.getParameter("name");
	String sMail = request.getParameter("email");
	String sTitle = request.getParameter("title");
	String sContent = request.getParameter("content");
	String sPwd = request.getParameter("pwd");
	
	String DB_URL = "jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=utf8";
//	String DB_URL = "jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=utf8";
	String DB_USER = "root";
	String DB_PASSWORD = "root";
	
	Statement stmt;
	  
	String query = "INSERT INTO GUEST(NAME,EMAIL,TITLE,CONTENT,MOMENT,PASSWORD,HIT) VALUES ('"+sName+"','"+sMail+"','"+sTitle+"','"+sContent+"',now(),'"+sPwd+"',0)";
	
	try {
		Class.forName("com.mysql.jdbc.Driver");
		Connection conn = DriverManager.getConnection(DB_URL,DB_USER,DB_PASSWORD);
		
		stmt = conn.createStatement();
		stmt.executeUpdate(query);
		stmt.close();
		conn.close();
		
		response.sendRedirect("list.jsp");

	}catch(Exception e){e.printStackTrace();}
%>